<!doctype html>
<html>
  <head>
    <meta content="text/html; charset=utf-8" />
    <title>Socket.io</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js" integrity="sha512-q/dWJ3kcmjBLU4Qc47E4A9kTB4m3wuTY7vkFJDTZKjTs8jhyGQnaUrxa0Ytd0ssMZhbNua9hE+E7Qv1j+DyZwA==" crossorigin="anonymous"></script>
  </head>
  <body>
    <h3 id="text"></h3>
  </body>

  <script type="text/javascript" charset="utf-8">
    var socket = io();
    socket.on('connect', function() {
        socket.emit('my event', {data: 'I\'m connected!'});
    });
    socket.on('message', (message) => {
      var h3 = document.getElementById('text');
      console.log(h3);
      h3.innerHTML = message;
    });
  </script>
</html>
